import copy

a = ['a', 'b', 'c', ['bb', 'cc']]


'''
   1、父层都拷贝值
   2、copy的子层拷贝地址；deepcopy值满满
'''

b = copy.copy(a)
c = copy.deepcopy(a)
# 改原对象
a.append("xyz")
a[-2].append('dd')
# 比较影响
print(a,b,c)


'''
自定义对象的 deep/shallow copy
'''


class CPU:
    pass

class MobilePhone:
    def __init__(self, cpu:CPU):
        self.cpu = cpu

c = CPU()
m = MobilePhone(c)

m1 = copy.copy(m)
m2 = copy.deepcopy(m)
print(id(m1), id(m))
print(id(m1.cpu), id(m.cpu))

print(id(m2), id(m))
print(id(m2.cpu), id(m.cpu))